# -*- coding: utf-8 -*- utile pour Scipe
# real glider Valenta Thermik XL 
# with afLs +butterfly
# with electric motor  
MODUL 10 22.5 # jeti 10 channels PPM frame 22.5 msec 
#____________flight conditions (5 )_____________________________________________
# main flight conditions: 3 position switch S4
att 		PHASE 	@S4b      #main phase landing ( attérissage)
vol.mot 	PHASE 	@S4a      #main phase motor launch
# S4 centered = normal flight
# secondary fligh conditions with the switch S5, 3 positions , on the left stick
vol.therm 	PHASE  	@S5b	#  slow (thermal)
vol.vitesse 	PHASE  	@S5a	#  speed
vol		PHASE		#  normal flight condition
CALL start_g
CALL start_Me
#________________main flight control functions, permanently assigned to a transmitter controls______________________________
CALL ctxMx 2  ail 
CALLP ctxMx  3 prof 
#  the trim for the elevator can be different for each flight conditions
prof.trim: INIT 0.03 att 
prof.trim: INIT 8.15 vol 
prof.trim: INIT 0.00 vol.therm 
prof.trim: INIT 0.00 vol.vitesse 
prof.trim: INIT 0.00 vol.mot 
END
CALL ctxMx 4 rud 
CALLP ctxM1_ge # -> courb brake thr
courb.trim: INIT 0.00 vol
courb.trim: INIT -3.00 vol.vitesse
courb.trim: INIT 5.00 vol.therm
courb.trim: INIT 10.00 att
END
#____vario___________
vario 	ADD @C2 
IF vol.mot
  vario = -100
ENDIF
IF att
  vario = -100
ENDIF

#________airbake : combine with butterfly ____________________________________
# variable afL controls the airbrakes
# variable brake controls the butterfly in the al2 fl2 modules 
# default behaviour: airbrake without butterfly
af  = brake # brake is the original control from stick M1, replaced by af
afL = brake # control the airbrakes  0-100
afB = 0   #   control the butterfly 0-100 (name = brake in the modules al2 + fl2)
afC: INIT 45.00 
IF @S2 # combine af 0->afC= spoiler, af afC-> 100-> butterfly
	afL  LINE   brake -100 0    2 0   afC:  100       100 100
 	afB  LINE   brake -100 0           afC:    0       100 100 
ENDIF  
brake = afB
#________ control surfaces___________________________________
CALL al2  2  5# 2 ailerons on channels 2 5
CALL fl2  6  7  # 2 flaps
CALL xtail 3 4

afL.U: INIT -100.00
afL.D: INIT 85.60
afL.s   SERV afL afL.U: afL.D: afL.D:
#____________ output : assign other receiver channels___________________________________________________________
vario.s SERV vario 100 0 -100
@V1	OUTN thr 	1.55 .55
@V8	OUTN afL.s	1.55 .55
@V9	OUTN vario	1.55 .55
#_____________travel______________________________________
# V1 motor
# V8 airbrake 1010=down 2079 = out
@XailL   TRAVEL @V2  	1.010 -22	1.556 0	2.069 17
@XailR   TRAVEL @V5  	1.010 12	1.286 0	2.064 -27
@XflapL  TRAVEL @V6  	1.010 -12	1.259 0	2.071 36
@XflapR  TRAVEL @V7  	1.010 36	1.558 0	2.069 -12
@Xprof   TRAVEL @V3  	1.010 15	1.558 0	2.098 -15
@Xrud    TRAVEL @V4  	1.010 -35	1.558 0	2.098 25


